import QtQuick 1.0

/* A view of "parents", which can include
   song folders, playlists, or podcast subscriptions */


ListView {
    Keys.onPressed: {
        if ((event.key == Qt.Key_Right) || (event.key == Qt.Key_Tab))  {
            if (itemsListModel.rowCount() > 0) {
                flickableView.state = "Episodes";
                event.accepted = true;
            }
        }
        else if ((event.key == Qt.Key_Left) || (event.key == Qt.Key_Backtab)) {
            if (playListModel.rowCount() > 0) {
                flickableView.state = "Playlist";
                event.accepted = true;
            }
        }
    }
    id: parentListView
    objectName: "parentListView"
    model: m3uListModel
    delegate: parentListDelegate;
    width: parent.width
    height: parent.height
    highlightFollowsCurrentItem: true;
    highlight: SongItem { color: "yellow" }
    preferredHighlightBegin: 80;
    preferredHighlightEnd: 220
    highlightRangeMode: ListView.ApplyRange
    focus: true
    clip: true

    Component {
        id: parentListDelegate;
        Item {
            id: parentItem;
            width: parent.width
            height: 45;
            clip: true;
            SongItem {
                id: background
                z: -1
                x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
                border.color: "green"
                radius: 5
                StyledText {
                    id: viewText
                    text: name;
                }
                MouseArea {
                    anchors.fill: parent
                    onClicked: mainWindow.openPlayListI(index);
                }
            }
        }
    }
}

